package com.vcms.utility.loader;

import com.vcms.entity.store.item.DrinksStoreItem;
import com.vcms.entity.store.itemtype.DrinksBrand;

/**
 * Title: VMCS Description: Copyright: Copyright (c) 2001 Company: ISS
 * 
 * @author Pang Pingli
 * @version 1.0
 */

public class DrinkPropertyLoader extends PropertyLoader {

	public DrinkPropertyLoader(String filen) {
		super(filen);
	}

	public DrinksStoreItem getItem(int idx) {
		DrinksStoreItem cit;

		DrinksBrand db = new DrinksBrand();
		String item, itemv;

		item = new String("Name" + idx);
		itemv = getValue(item);

		db.setName(itemv);

		item = new String("Price" + idx);
		itemv = getValue(item);
		db.setPrice(Integer.parseInt(itemv));

		item = new String("Quantity" + idx);
		itemv = getValue(item);

		cit = new DrinksStoreItem(db, Integer.parseInt(itemv));

		return cit;
	}

	public void setItem(int it, DrinksStoreItem item) {
		String itn;
		DrinksBrand cn;
		int idx = it + 1;

		cn = (DrinksBrand) item.getContent();
		itn = new String("Name" + idx);

		setValue(itn, cn.getName());

		itn = new String("Price" + idx);
		setValue(itn, String.valueOf(cn.getPrice()));

		itn = new String("Quantity" + idx);
		setValue(itn, String.valueOf(item.getQuantity()));
	}

}
